package com.itheima.service;

import com.itheima.dao.StuDaoInter;
import com.itheima.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class StuService implements StuServiceInter {
    @Autowired
    private StuDaoInter stuDaoInter;
    public List<Student> listStudent(){
        List<Student> studentList = stuDaoInter.listStudent();
        studentList.stream().forEach(student -> {
            if("1".equals(student.getGender())){
                student.setGender("男");
            }else if("2".equals(student.getGender())){
                student.setGender("女");
            }

            Integer score = student.getScore();
            if(score >= 85){
                student.setLevel("优秀");
            }else if(score >= 60){
                student.setLevel("及格");
            }else{
                student.setLevel("不及格");
            }
        });
        return studentList;
    }
}
